#!/bin/bash

#备份现有yum源,保存到/etc/yum.repos.d/bak目录下
mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak

# 挂载光盘
mount /dev/sr0 /mnt &> /dev/null
echo '/dev/sr0	/mnt	iso9660 defaults	0 0' >> /etc/fstab

#编辑本地源
cat << eof > /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
enabled=1
gpgcheck=0
eof

yum clean all &> /dev/null

yum repolist
